<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var num = prompt('请输入班级总人数');
        var sum = 0;
        for (var i = 1; i <= num; i++) {
            var score = prompt('请你输入第' + i + '个学生成绩');
            //因为从prompt取过来的数据是 字符串型的需要转换成数字型
            sum += parseFloat(score);
        }
        alert('班级平均成绩为:' + sum / num);
    </script>
</head>

<body>

</body>

</html>